package com.yitongmao.common;


import com.yitongmao.common.reminder.ReaderApplication;
import com.yitongmao.common.sharesdk.Account;
import com.yitongmao.core.cache.ACache;
import com.yitongmao.util.StringUtils;


public class AppDateCommon {

    private String AesKey = "newaircloud_vjow9Dej#JDj4[oIDF";
    private volatile static AppDateCommon instance;

    public ACache mCache;
    public String sid;

    private boolean isVerifyLock = false;

    public boolean isBackground = false;

    private AppDateCommon() {
        mCache = ACache.get(ReaderApplication.applicationContext);
    }

    public static AppDateCommon getInstance() {
        if (instance == null) {
            synchronized (AppDateCommon.class) {
                if (instance == null) {
                    instance = new AppDateCommon();
                }
            }
        }
        return instance;
    }

    public String getAesKey(){
        return AesKey;
    }

    public void setSid(String sid){
        this.sid = sid;
    }

    public String getSid(){
        if (!StringUtils.isBlank(sid))
            return sid;
        else
            return getAccountInfo().getSid();
    }

    public boolean isVerifyLock() {
        return isVerifyLock;
    }

    public void setVerifyLock(boolean verifyLock) {
        isVerifyLock = verifyLock;
    }

    public Account getAccountInfo() {
        Account account = null;
        String account_str = mCache.getAsString(AppConstants.memberCenter.KEY_CACHE_MY_LOGIN);
        if (account_str != null && !account_str.trim().equals("")) {
            account = Account.objectFromData(account_str);
        }
        return account;
    }


}
